//
//  CHMessageVisitorView.swift
//  status
//
//  Created by 彳亍 on 2017/3/22.
//  Copyright © 2017年 彳亍. All rights reserved.
//

import UIKit
import SnapKit

class CHMessageVistorView: CHVisitorView {
    
    /// 消息图片
    fileprivate lazy var imageView = UIImageView(image: UIImage(named: "visitordiscover_image_message"))
    /// 文本
    fileprivate lazy var sloganLabel:UILabel = UILabel(text: nil, textColor: UIColor.darkGray,fontSize:12)
    /// 注册按钮
    fileprivate lazy var registerButton:UIButton = UIButton(title: "注册",
                                                            titleColor: UIColor.orange,
                                                            backgroundImage: UIImage(named:"common_button_white_disable"),
                                                            target: self,
                                                            action: #selector(register))
    /// 登录按钮
    fileprivate lazy var loginButton:UIButton = UIButton(title: "登录",
                                                         titleColor: UIColor.darkGray,
                                                         backgroundImage: UIImage(named:"common_button_white_disable"),
                                                         target: self,
                                                         action: #selector(login))
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        // 设置UI
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override var visitorInfo: [String : String]? {
        didSet {
            sloganLabel.text = visitorInfo?["message"]
        }
    }
    
    /// 注册
    override func register() {
        super.register()
    }
    
    /// 登录
    override func login() {
        super.login()
    }
    
    
}

// MARK: - UI
extension CHMessageVistorView {
    
    /// 设置UI
    fileprivate func setupUI() {
        // 添加视图
        addSubview(imageView)
        addSubview(sloganLabel)
        addSubview(registerButton)
        addSubview(loginButton)
        
        // 布局
        imageView.snp.makeConstraints { (ConstraintMaker) in
            ConstraintMaker.centerX.equalToSuperview()
            ConstraintMaker.centerY.equalToSuperview().offset(-80)
        }
        
        sloganLabel.snp.makeConstraints { (ConstraintMaker) in
            ConstraintMaker.centerX.equalToSuperview()
            ConstraintMaker.top.equalTo(imageView.snp.bottom)
            ConstraintMaker.width.equalTo(220)
        }
        
        registerButton.snp.makeConstraints { (ConstraintMaker) in
            ConstraintMaker.top.equalTo(sloganLabel.snp.bottom).offset(8)
            ConstraintMaker.right.equalTo(sloganLabel.snp.centerX).offset(-8)
            ConstraintMaker.width.equalTo(97)
        }
        
        loginButton.snp.makeConstraints { (ConstraintMaker) in
            ConstraintMaker.top.equalTo(sloganLabel.snp.bottom).offset(8)
            ConstraintMaker.left.equalTo(sloganLabel.snp.centerX).offset(8)
            ConstraintMaker.width.equalTo(97)
        }
        
        
    }
    
    
}





